package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Task;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class TaskVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "任务名称")
    private String taskName;

    @ApiModelProperty(value = "任务内容")
    private String content;

    @ApiModelProperty(value = "优先级：1低2中3高")
    private Integer priority;

    @ApiModelProperty(value = "创建人id")
    private Integer createAdminId;

    @ApiModelProperty(value = "负责人id")
    private Integer chargeAdminId;

    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date stopTime;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "描述")
    private String description;


    @ApiModelProperty(value = "是否删除 0否 1是")
    private Integer isDelete;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Task convert(TaskVO vo) {
        Task entity = new Task();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Task> convertList(List<TaskVO> list) {
        List<Task> resultList = new ArrayList<>();
        for (TaskVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
